package com.jc.utils;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Calendar;

public class RateUtils {
	
	public static BigDecimal calculateProfit(BigDecimal totalAmt,Integer duration,BigDecimal rate){
		Calendar cal = Calendar.getInstance();
		int maxDayNum = cal.getActualMaximum(Calendar.DAY_OF_YEAR);
		return totalAmt.multiply(new BigDecimal(duration)).multiply(rate).divide(new BigDecimal(maxDayNum*100),2,RoundingMode.CEILING);
	}
	
	public static BigDecimal calculateCunrrentProfit(BigDecimal totalAmt,Integer duration,BigDecimal rate){
		Calendar cal = Calendar.getInstance();
		int maxDayNum = cal.getActualMaximum(Calendar.DAY_OF_YEAR);
		return totalAmt.multiply(new BigDecimal(duration)).multiply(rate).divide(new BigDecimal(maxDayNum*100),2,RoundingMode.FLOOR);
	}
}
